Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
GraphQL: problema con el código de la página del tutorial, aparece un error "Se esperaba que no definido fuera un esquema de GraphQL".

Intento aprender GraphQL. Quería probar el código que se encuentra en la sección Primeros pasos con GraphQL.js en graphql.org. Creé un archivo server.js como dice esta página: https://graphql.org/graphql-js/

Seguí instrucciones como :

 npm init npm install graphql --save

El archivo package.json se ve así:

 { "name": "graphql", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "graphql": "^16.0.1" } }

El archivo server.js que creé se ve exactamente como el de la página (fue copiado):

 var { graphql, buildSchema } = require('graphql'); // Construct a schema, using GraphQL schema language var schema = buildSchema(` type Query { hello: String } `); // The root provides a resolver function for each API endpoint var root = { hello: () => { return 'Hello world!'; }, }; // Run the GraphQL query '{ hello }' and print out the response graphql(schema, '{ hello }', root).then((response) => { console.log(response); });

Pero después de usar el comando node server.js (como está escrito en la página) en la terminal, aparece este error:

 node_modules\graphql\type\schema.js:35 throw new Error( ^ Error: Expected undefined to be a GraphQL schema. at assertSchema (F:\GraphQL\node_modules\graphql\type\schema.js:35:11) at validateSchema (F:\GraphQL\node_modules\graphql\type\validate.js:34:28) at graphqlImpl (F:\GraphQL\node_modules\graphql\graphql.js:52:64) at F:\GraphQL\node_modules\graphql\graphql.js:21:43 at new Promise (<anonymous>) at graphql (F:\GraphQL\node_modules\graphql\graphql.js:21:10) at Object.<anonymous> (F:\GraphQL\server.js:18:1) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32)

Alguien sabe cual es el problema? ¿Quizás me estoy perdiendo algún paquete? ¿O el código dado en la página es incorrecto? Por favor ayúdenme, gracias de antemano por cualquier respuesta.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!